def register():    

    IDname();
    MYemall();
    MYIDCARD();
    MYNAME();
    
def IDname():
    ID = input("请输入ID（ID长度不能超过8位，且只能由数字、字母、下划线组成）:")
    if check_ID(ID):
        print('{} 用户名注册成功'.format(ID))
    else:
        print('{} 用户名不合法，请重新输入!')
        return IDname();
def MYemall():
    EMALL= input("请输入邮箱（EMAIL地址要求符合基本电子邮件格式）:")
    if check_EMALL(EMALL):
        print('{} EMAIL地址合法:'.format(EMALL))
    else:
        print('{} EMAIL地址不合法，请重新输入:'.format(EMALL))
        return MYemall();
def MYIDCARD():
    IDCARD= input("请输入身份证号（身份证号要求符合基本格式）:")
    if check_IDCARD(IDCARD):
        print('{} IDCARD合法:'.format(IDCARD))
        if get_sex(IDCARD) == 0:
             print('该用户性别为女')
           
        else:
             print('该用户性别为男')
    else:
        print('{} IDCARD不合法，请重新输入:'.format(IDCARD))
        return MYIDCARD();
def MYNAME():
    NAME= str(input("请输入姓名（姓名只能中文且不能超过4位）:"))
    if check_NAME(NAME):
        
        print('{} NAME合法:'.format(NAME))
        
    else:
        print('{} NAME不合法，请重新输入:'.format(NAME))
        return MYNAME();

    
def check_ID(ID):
    if len(ID)> 8 or len(ID) == 0:
        return False
    if '_' in ID:        
        x = ID.replace('_','x')        
        if x.isalnum():
            return True
        
    return True 
def check_EMALL(EMALL):   
    if '@' not in EMALL or '.' not in EMALL:
        return False    
    if len(EMALL[0:EMALL.index('@')])==0:
        return False
    if len(EMALL[EMALL.index('.')+1:])==0:
        print(len(EMALL[-1:EMALL.index('.')]))
        return False

    return True

def check_IDCARD(IDCARD):  
    if len(IDCARD) != 18:
        return False
        
    return True
def check_NAME(NAME):
    if len(NAME) >= 4:
        return False

    return True

def get_sex(IDCARD):        
         num = int(IDCARD[16:17])
         if num % 2 == 0:
             return 0
         else:
             return 1

   
register()



